package com.stox.repository.spring.data.jpa;

import java.util.Set;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.stox.model.Watchlist;

public interface WatchListJpaRepository  extends JpaRepository<Watchlist, Long>{

	public Set<Watchlist> findByParentId(Long id);
	
	@Modifying
	@Query("update Watchlist w set w.name = :name where w.id = :id")
	public void rename(@Param("id") Long id, @Param("name") String newName);
	
	@Modifying
	@Query("delete from Watchlist w where w.parentId = :id")
	public void deleteByParentId(@Param("id") Long parentId);
}
